import './public-path'
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { Message } from '@garco-design/web-vue';
// import store from './store'
import globalComponents from '@/components';
import '@/icons'
import ArcoVue from '@garco-design/web-vue'
import ArcoVueIcon from '@garco-design/web-vue/es/icon'
import VueECharts from 'vue-echarts'
import '@garco-design/web-vue/dist/arco.min.css'
import './style/index.scss'
let app = null
export function render (props = {}) {
  const { container } = props
  if (props) {
    // 注入 actions 实例
    // actions.setActions(props)
  }
  app = createApp(App)
  Message._context = app._context;
  app.use(router)
  app.use(ArcoVue)
  app.use(ArcoVueIcon)
  app.use(globalComponents);
  app.component('v-chart', VueECharts)
  app.config.errorHandler = (err, vm, info) => {
    console.log(err, vm, info)
  }
  app.mount(container ? container.querySelector('#root-monitor') : '#root-monitor')
}
// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  render()
}
export async function bootstrap (props) {
  console.log('现在进入子应用c-child的bootstraped阶段', props)
}
export async function mount (props) {
  console.log('进入子应用--backup--mount')
  render(props)
}
export async function update (props) {
  console.log('--backup--update')
  render(props)
}
export async function unmount (props) {
  console.log('离开子应用--backup--unmount')
  app.unmount()
  app._container.innerHTML = ''
  app = null
}
